<?php

/**
 * TestCommand class
 *
 * @author Julot <andy.julot@gmail.com>
 * @since Monday, August 8, 2011. 10:15 AM
 */
class TestCommand extends CConsoleCommand {

	public function getHelp() {
		return <<<EOD
USAGE
    test
DESCRIPTION
    Just a playground.
EOD;
	}

	public function run($args) {
		$this->_mail();
	}

	protected function _mail() {
		echo "Send mail.";
		$message = new MailMessage('Test Mail Component');
		$message->setBody('Testing mail component');
		$message->addTo('andy.julot@gmail.com');
		$message->from = Yii::app()->params['admin']['email'];
		Yii::app()->mail->send($message);
	}

	protected function _splitFrom($value='Andy Julot <andy.julot@gmail.com>') {
		$values = explode('<', $value);
		$froms = array();
		if (count($values) == 1 || trim($values[0]) == '') {
			$value = str_replace(array('<', '>'), array('', ''), $value);
			$values = explode('@', $value);
			$froms['name'] = trim($values[0]);
			$froms['contact'] = trim($value);
		} else {
			$froms['name'] = trim($values[0]);
			$froms['contact'] = str_replace('>', '', trim($values[1]));
		}
		return $froms;
	}

	protected function _folder() {
		$folder = new Folder('K:/Website/Stratos4/Ayamo/files/gallery');
		var_dump($folder->listData());
	}

	protected function _twitter() {
		echo "Regular Expression Testing\n";
		$subject = '07:25 RT @TMCPoldaMetro: Antrean kendaraan (cont) asdfasd';
		if (!preg_match("/@.+:|(cont)/i", $subject)) {
			print "A match was not found.";
		} else {
			print "A match was found.";
		}
	}

}
